<?php
if(isset($form['#distributor_id']) && !empty($form['#distributor_id'])){
    echo get_template_header_info($form['#distributor_id'],'distributor');
}
?>
<div class="hp-tab-newprd">
        <ul class="j-sw-nav">
            <?php if(empty($_GET['distributor_id'])){?>
                <li class="newprd-s1 tab-li"><a href="<?php echo base_path();?>stock_info/list">查看</a></li>
                <?php if(user_access('add stock_info')){?>
                <li class="newprd-s2 tab-li<?php if(arg(1) == 'add'){?> on <?php }?>"><a href="<?php echo base_path();?>stock_info/add">添加</a></li>
                <?php } if(user_access('view stock_info stats')){?>
                <li class="newprd-s3 tab-li"><a href="<?php echo base_path();?>stock_info/stats">统计</a></li>
                <?php } if(arg(1) == 'edit' && !empty(arg(2))){?>
                    <li class="newprd-s4 tab-li on"><a href="javascript:void(0)">修改</a></li>
                <?php }
                if(arg(1) == 'clone'){?>
                <li class="newprd-s5 tab-li on"><a href="javascript:void(0)">克隆</a></li>
            <?php }
            }else{ ?>
                <?php echo get_tab($form['#distributor_id'],'stock_info','distributor')?>
            <?php }?>
        </ul>
        <div class="table-div">
            <?php if(isset($form['#distributor_id'])&& !empty($form['#distributor_id'])){?>
            <ul class="table-ul-li">
                <li><a href="<?php echo base_path(); ?>stock_info/list?distributor_id=<?php echo $form['#distributor_id']?>">列表</a></li>
                <?php if(user_access('add stock_info')){?>
                <li>|</li>
                <li><a href="<?php echo base_path(); ?>stock_info/add?distributor_id=<?php echo $form['#distributor_id']?>" <?php if(arg(1) == "add" && !empty($_GET['distributor_id'])){?>class="selected"<?php }?>>添加</a></li>
                <?php }
                if(arg(1) == "edit" && !empty($_GET['distributor_id'])){?>
                    <li>|</li>
                    <li class="selected">详情</li>
                <?php }?>
            </ul>
            <?php }?>
        <div class="small-select small-input column" style="clear:both">
            <div class="small-div"><div class="form-label">上报人:</div><?php print render($form['stock_info_author']['author']); ?></div>
<!--            <div class="small-div"><div class="form-label">请选经销商:</div>--><?php //print render($form['stock_info_distributor']['distributor']); ?></div>
            <div class="small-select big-input column" style="clear:both">
                <div class="max-big-input address-search" <?php  if(isset($_GET['distributor_id']) && !empty($_GET['distributor_id'])) {  echo "style='display: none'"; } ?>>
                    <div class="form-label"><span class="required">*</span>请选经销商:</div>
                    <?php print render($form['distributor_name']);
                    print render($form['select_distributor_button']);
                    ?>
                </div>
        </div>
        <div class="small-select small-input column" style="clear:both">
            <div class="small-div"><div class="form-label">请选年份:</div><?php print render($form['stock_info_date']['year']); ?></div>
            <div class="small-div"><div class="form-label">请选月份:</div><?php print render($form['stock_info_date']['month']); ?></div>
        </div>
        <div class="max-select small-input column" style="clear:both">
            <div class="form-label"><span class="required">*</span>化肥品种:</div><?php print render($form['stock_info_sacf']['sacfvariety']); ?>
        </div>
        <div class="small-select small-input column" style="clear:both">
            <div class="small-div"><div class="form-label"><span class="required">*</span>上月库存(吨):</div><?php print render($form['stock_info_amount']['last_month_stock']); ?></div>
            <div class="small-div"><div class="form-label"><span class="required">*</span>退库数量(吨):</div><?php print render($form['stock_info_amount']['return_stock']); ?></div>
        </div>
        <div class="small-select small-input column" style="clear:both">
            <div class="small-div"><div class="form-label"><span class="required">*</span>本月入库(吨):</div><?php print render($form['stock_info_amount']['this_month_instock']); ?></div>
            <div class="small-div"><div class="form-label"><span class="required">*</span>本月出库(吨):</div><?php print render($form['stock_info_amount']['this_month_outstock']); ?></div>
        </div>
        <div class="small-select small-input column" style="clear:both">
            <div class="small-div"><div class="form-label"><span class="required">*</span>本月库存(吨):</div><?php print render($form['stock_info_amount']['this_month_stock']); ?></div>
            <div class="small-div"><div class="form-label"><span class="required">*</span>本月销量(吨):</div><?php print render($form['stock_info_amount']['this_month_sales']); ?></div>
        </div>
        <div  style="clear:both">
            <div class="form-label">详细信息:</div><div style="margin-left: 11.3em;margin-top: 10px "><?php print render($form['stock_info_amount']['details']); ?></div>
        </div>
        <div class="add-submit" style="text-align: center"><?php print render($form['submit']); ?></div>
    </div>
</div>

<?php print drupal_render_children($form); ?>
</div></form>
<div>
    <div class="modal fade" id="distributorModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close"
                            data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                        选择经销商
                    </h4>
                </div>
                <div class="modal-body">
                    <?php echo @render(drupal_get_form('distributor_select_list_form'),$_GET['addr_id']?$_GET['addr_id']:'');?>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default"
                            data-dismiss="modal">关闭
                    </button>

                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
</div>
<form><div>
